package cn.kgc.util;

import cn.kgc.pojo.User_info;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

import java.io.UnsupportedEncodingException;

public class TokenUtils {
    public static String getToken(User_info user) {
        System.out.println("user="+user);
        String token="";
        try {
            token= JWT.create().withAudience(user.getUsername())
                    .sign(Algorithm.HMAC256(user.getPassword()));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.out.println("token="+token);
        return token;


    }
}
